package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Book;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface BookMapper extends BaseMapper<Book> {

    @Select("SELECT category, COUNT(*) AS count FROM book GROUP BY category")
    List<Map<String, Object>> getCategoryBorrowCount();

    @Select("SELECT SUM(total) FROM book")
    Integer count();


    @Select("SELECT SUM(available) FROM book")
    int getRemain();

    @Select("SELECT SUM(total) FROM book")
    int getTotal();


}
